package com.jimet.servlets;

import java.util.Hashtable;
import java.util.MissingResourceException;
import java.util.ResourceBundle;


public class FormValidatorAjaxProperty {
	private static boolean isInitialized = false;
	private static Hashtable<String,ResourceBundle> RESOURCE_BUNDLE; 
	private static final String BUNDLE_NAME_TR = "com.jimet.servlets.FormValidatorMessages_TRK"; //$NON-NLS-1$
	private static final String BUNDLE_NAME_ENG = "com.jimet.servlets.FormValidatorMessages_ENG"; //$NON-NLS-1$
	
	private static final ResourceBundle RESOURCE_BUNDLE_TR = ResourceBundle
			.getBundle(BUNDLE_NAME_TR);
	private static final ResourceBundle RESOURCE_BUNDLE_ENG = ResourceBundle
			.getBundle(BUNDLE_NAME_ENG);	

	private static synchronized void initialize() {
		if (!isInitialized)
		{
			RESOURCE_BUNDLE = new Hashtable<String,ResourceBundle>();
			RESOURCE_BUNDLE.put("TR",RESOURCE_BUNDLE_TR);
			RESOURCE_BUNDLE.put("ENG",RESOURCE_BUNDLE_ENG);
			isInitialized = true;
		}
	}

	public static String getString(String langCode, String key) {
		// TODO Auto-generated method stub
		try {
			initialize();
			ResourceBundle tmp = (ResourceBundle)RESOURCE_BUNDLE.get(langCode);
			return tmp.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		}
	}
}
